﻿<UserControl x:Class="WinnerSV.Views.AnteprimaSchedina"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    d:DesignHeight="480" d:DesignWidth="480" 
    DataContext="{Binding AnteSchedina, Mode=OneTime, Source={StaticResource Locator}}" >

    <Grid x:Name="LayoutRoot" Background="Transparent">
        <ListBox ItemsSource="{Binding ListScommesse, Mode=OneTime}" >
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Border BorderBrush="{StaticResource paletteWinnerYellowDark}" 
                            BorderThickness="1" 
                            Margin="2.5" 
                            CornerRadius="2" 
                            Background="{StaticResource PhoneChromeBrush}">
                        <StackPanel Orientation="Vertical" Margin="8">
                            <!-- Data e Teams -->
                            <TextBlock Text="{Binding Data}" 
                                       HorizontalAlignment="Center" />
                            <Grid Margin="0,4">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="40*" />
                                    <ColumnDefinition Width="20*" />
                                    <ColumnDefinition Width="40*" />
                                </Grid.ColumnDefinitions>

                                <TextBlock Grid.Column="0" 
                                           Text="{Binding Path=TeamCasa}" 
                                           FontSize="{StaticResource PhoneFontSizeMediumLarge}"
                                           TextWrapping="Wrap"
                                           HorizontalAlignment="Left"
                                           VerticalAlignment="Center" />
                                <TextBlock Grid.Column="1"
                                           Text="VS" 
                                           FontWeight="Bold" 
                                           HorizontalAlignment="Center"
                                           VerticalAlignment="Center" />
                                <TextBlock Grid.Column="2" 
                                           Text="{Binding Path=TeamFCasa}"
                                           FontSize="{StaticResource PhoneFontSizeMediumLarge}"
                                           HorizontalAlignment="Right"
                                           VerticalAlignment="Center"
                                           TextWrapping="Wrap" />
                            </Grid>
                            <!-- 1X2 -->
                            <StackPanel Orientation="Vertical" 
                                    Margin="0,8"
                                    Visibility="{Binding ConverterParameter=1X2, Converter={StaticResource ScommessaConverter}, Mode=OneWay}" >
                                <TextBlock>
                                    <Run Text="{Binding LocalizedResources.Scommessa1X2Title, Mode=OneWay, Source={StaticResource LocalizedStrings}}" />
                                </TextBlock>
                                <TextBlock Visibility="{Binding Q1, Converter={StaticResource StringToVisConverter}}" Margin="4,0,0,0">
                                    <Run Text="{Binding LocalizedResources.ScommessaVittoria, Mode=OneWay, Source={StaticResource LocalizedStrings}}" />
                                    <Run Text=": " />
                                    <Run Text="{Binding TeamCasa}" />
                                    <Run Text="{Binding Q1, StringFormat=' {0}'}" />
                                </TextBlock>
                                <TextBlock Visibility="{Binding QX, Converter={StaticResource StringToVisConverter}}" Margin="4,0,0,0">
                                    <Run Text="{Binding LocalizedResources.ScommessaPareggio, Mode=OneWay, Source={StaticResource LocalizedStrings}}" />
                                    <Run Text=": " />
                                    <Run Text="{Binding QX}" />
                                </TextBlock>
                                <TextBlock Visibility="{Binding Q2, Converter={StaticResource StringToVisConverter}}" Margin="4,0,0,0">
                                    <Run Text="{Binding LocalizedResources.ScommessaVittoria, Mode=OneWay, Source={StaticResource LocalizedStrings}}" />
                                    <Run Text=": " />
                                    <Run Text="{Binding TeamFCasa}" />
                                    <Run Text="{Binding Q2, StringFormat=' {0}'}" />
                                </TextBlock>
                            </StackPanel>
                            
                            <!-- Over/Hunder -->
                            <StackPanel Visibility="{Binding ConverterParameter=OverUnder, Converter={StaticResource ScommessaConverter}, Mode=OneWay}"
                                    Margin="0,8">
                                <TextBlock>
                                    <Run Text="{Binding LocalizedResources.ScommessaOverUnderTitle, Mode=OneWay, Source={StaticResource LocalizedStrings}}" />
                                    <Run Text=": " />
                                    <Run Text="{Binding TotalScore}" />
                                </TextBlock>
                                <TextBlock Visibility="{Binding OVER, Converter={StaticResource StringToVisConverter}}" Margin="4,0,0,0">
                                    <Run Text="{Binding LocalizedResources.ScommessaOver, Mode=OneWay, Source={StaticResource LocalizedStrings}}" />
                                    <Run Text=": " />
                                    <Run Text="{Binding OVER}" />
                                </TextBlock>
                                <TextBlock Visibility="{Binding UNDER, Converter={StaticResource StringToVisConverter}}" Margin="4,0,0,0">
                                    <Run Text="{Binding LocalizedResources.ScommessaUnder, Mode=OneWay, Source={StaticResource LocalizedStrings}}" />
                                    <Run Text=": " />
                                    <Run Text="{Binding UNDER}" />
                                </TextBlock>
                            </StackPanel>
                            <!-- Handicap -->
                            <StackPanel Visibility="{Binding ConverterParameter=Handicap, Converter={StaticResource ScommessaConverter}}"
                                    Margin="0,8" >
                                <TextBlock>
                                    <Run Text="{Binding LocalizedResources.ScommessaHandicapTitle, Mode=OneWay, Source={StaticResource LocalizedStrings}}" />
                                    <Run Text=": " />
                                    <Run Text="{Binding HC}" />
                                </TextBlock>
                                <TextBlock Visibility="{Binding HC1, Converter={StaticResource StringToVisConverter}}" Margin="4,0,0,0">
                                    <Run Text="{Binding LocalizedResources.ScommessaVittoria, Mode=OneWay, Source={StaticResource LocalizedStrings}}" />
                                    <Run Text=": " />
                                    <Run Text="{Binding TeamCasa}" />
                                    <Run Text="{Binding HC1, StringFormat=' {0}'}" />
                                </TextBlock>
                                <TextBlock Visibility="{Binding HCX, Converter={StaticResource StringToVisConverter}}" Margin="4,0,0,0">
                                    <Run Text="{Binding LocalizedResources.ScommessaPareggio, Mode=OneWay, Source={StaticResource LocalizedStrings}}" />
                                    <Run Text=": " />
                                    <Run Text="{Binding HCX}" />
                                </TextBlock>
                                <TextBlock Visibility="{Binding HC2, Converter={StaticResource StringToVisConverter}}" Margin="4,0,0,0">
                                    <Run Text="{Binding LocalizedResources.ScommessaVittoria, Mode=OneWay, Source={StaticResource LocalizedStrings}}" />
                                    <Run Text=": " />
                                    <Run Text="{Binding TeamFCasa}" />
                                    <Run Text="{Binding HC2, StringFormat=' {0}'}" />
                                </TextBlock>
                            </StackPanel>
                            <!-- DoppiaChance -->
                            <StackPanel Visibility="{Binding ConverterParameter=DoppiaChance, Converter={StaticResource ScommessaConverter}, Mode=OneWay}" 
                                    Margin="0,8" >
                                <TextBlock Text="{Binding LocalizedResources.ScommessaDoppiaChanceTitle, Mode=OneWay, Source={StaticResource LocalizedStrings}}" />
                                <TextBlock Visibility="{Binding DC1X, Converter={StaticResource StringToVisConverter}}" Margin="4,0,0,0">
                                    <Run Text="{Binding DC1X, StringFormat='1X: {0}' }" />
                                </TextBlock>
                                <TextBlock Visibility="{Binding DC12, Converter={StaticResource StringToVisConverter}}" Margin="4,0,0,0">
                                    <Run Text="{Binding DC12, StringFormat='12: {0}' }" />
                                </TextBlock>
                                <TextBlock Visibility="{Binding DCX2, Converter={StaticResource StringToVisConverter}}" Margin="4,0,0,0">
                                    <Run Text="{Binding DCX2, StringFormat='X2: {0}' }" />
                                </TextBlock>
                            </StackPanel>
                            <!-- Home Away -->
                            <StackPanel Visibility="{Binding ConverterParameter=HomeAway, Converter={StaticResource ScommessaConverter}, Mode=OneWay}"
                                    Margin="0,8" >
                                <TextBlock Text="{Binding LocalizedResources.ScommessaHomeAwayTitle, Mode=OneWay, Source={StaticResource LocalizedStrings}}" />
                                <TextBlock Visibility="{Binding Home12, Converter={StaticResource StringToVisConverter}}" Margin="4,0,0,0">
                                    <Run Text="{Binding LocalizedResources.ScommessaVittoria, Mode=OneWay, Source={StaticResource LocalizedStrings}}" />
                                    <Run Text=": " />
                                    <Run Text="{Binding TeamCasa}" />
                                    <Run Text="{Binding Home12, StringFormat=' {0}'}" />
                                </TextBlock>
                                <TextBlock Visibility="{Binding Away12, Converter={StaticResource StringToVisConverter}}" Margin="4,0,0,0">
                                    <Run Text="{Binding LocalizedResources.ScommessaVittoria, Mode=OneWay, Source={StaticResource LocalizedStrings}}" />
                                    <Run Text=": " />
                                    <Run Text="{Binding TeamFCasa}" />
                                    <Run Text="{Binding Away12, StringFormat=' {0}'}" />
                                </TextBlock>
                            </StackPanel>

                            <toolkit:ContextMenuService.ContextMenu>
                                <toolkit:ContextMenu>
                                    <toolkit:MenuItem Header="{Binding LocalizedResources.ContextMenuItemDelete, Mode=OneWay, Source={StaticResource LocalizedStrings}}" 
                                                    Command="{Binding AnteSchedina.DeleteScommessaCommand, Mode=OneWay, Source={StaticResource Locator}}" 
                                                    CommandParameter="{Binding}" />
                                </toolkit:ContextMenu>
                            </toolkit:ContextMenuService.ContextMenu>
                        </StackPanel>
                    </Border>
                </DataTemplate>
            </ListBox.ItemTemplate>
            <ListBox.ItemContainerStyle>
                <Style TargetType="ListBoxItem">
                    <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
                </Style>
            </ListBox.ItemContainerStyle>
        </ListBox>
    </Grid>
</UserControl>